package com.hjs.security;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Jiam extends HttpServlet {
	public Jiam() {
		super();
	}
	public void init() throws ServletException {
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		String jiami = request.getParameter("jmstr");
		String key = request.getParameter("key");
		System.out.println("加密数据:" + jiami);
		System.out.println("密钥:" + key);
		String a = "";
		try {
			a = DesString.ENCRYPTMethod(jiami, key).toUpperCase();
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("加密后的数据为:" + a);
		request.setAttribute("miwen",a);
		request.getRequestDispatcher("/string.jsp").forward(request, response);
	}
}
